// -----滚动-----
// var main = document.querySelector(".main");
// var mainHeight= main.offsetHeight;
// var header = document.querySelector(".header");
// window.onscroll=function setFull(){
//     var offsetTop = document.body.scrollTop||document.documentElement.scrollTop;
//     if(offsetTop<mainHeight){
      
//         opactiy = offsetTop/mainHeight;
//         header.style.background="ragb(" + opactiy + ")"
//     }
// }
// -----轮播图-----
window.onload=function(){
    lunBotu();
}
function lunBotu(){


var main = document.querySelector(".main");
var banner =document.querySelector(".banner");
var first = banner.querySelector("li:first-of-type");
var last = banner.querySelector("li:last-of-type");
banner.appendChild(first.cloneNode(true));
banner.insertBefore(last.cloneNode(true),banner.firstChild)
var lis=banner.querySelectorAll("li");
var count = lis.length;
var mainWidth=main.offsetWidth;
console.log(mainWidth);
banner.style.width = count*mainWidth +"px";
for(var i = 0; i<lis.length; i++){
     lis[i].style.width=mainWidth + "px";
  }
   var index = 1;
   banner.style.left=-mainWidth + "px";
 

var startTime = function(){
    timerId=setInterval(function () {
        index++;
        banner.style.transition="left 0.5s ease-in-out";
        banner.style.left=(-index*mainWidth) + "px";
        setTimeout(function(){
        if(index==count-1){
            index=1;
          banner.style.transition="none";
           
            banner.style.left=-index*mainWidth + "px";
        }
    },500)
    },2000)
}
startTime();
}
// 倒计时
function timeOut(){
    var spans=document.querySelector(".time").querySelectorAll("span");
    var totalTime=3700;
    var timerId=setInterval(function(){
        totalTime--;
        if(totalTime < 0){
            clearInterval(timerId);
            return;
        }
        var hour=Math.floor(totalTime/3600);
        var minute=Math.floor(totalTime%3600/60);
        var second=Math.floor(totalTime%60);
    })
} 